#include <string.h>
#include <omnetpp.h>


class Node_ : public cSimpleModule
{
  protected:
    // The following redefined virtual function holds the algorithm.
    virtual void initialize();
    virtual void handleMessage(cMessage *msg);

  private:
    cMessage *msg;
    cMessage *event;
};

// The module class needs to be registered with OMNeT++
Define_Module(Node_);

void Node_::initialize()
{
    /*
    //expontential
    if (strcmp("node1", getName()) == 0)
    {
        msg = new cMessage("expo");
        send(msg, "gate$o");
    }
    //poisson
    if (strcmp("node3", getName()) == 0)
    {
        msg = new cMessage("poisson");
        send(msg, "gate$o");
    }
    //onoff
    if (strcmp("node5", getName()) == 0)
    {
        msg = new cMessage("onoff");
        send(msg, "gate$o");
    }
    //mmpp
    if (strcmp("node7", getName()) == 0)
    {
        msg = new cMessage("mmpp");
        send(msg, "gate$o");
    }*/
}

void Node_::handleMessage(cMessage *msg)
{
  /*  if(msg == event)
    {
        if((msg -> getFullName())=="event-exp")
        {
            msg = new cMessage("expo");
        }
        if((msg -> getFullName())=="event-poisson")
        {
            msg = new cMessage("poisson");
        }
        if((msg -> getFullName())=="event-onoff")
        {
            msg = new cMessage("onoff");
        }
        if((msg -> getFullName())=="event-mmpp")
        {
            msg = new cMessage("mmpp");
        }
        send(msg, "gate$o");
    }
    else
    {
        simtime_t delay;

        if((msg -> getFullName())=="expo")
        {
           delay = exponential(3);
           event = new cMessage("event-exp");
        }
        else
        {
            if((msg -> getFullName())=="poisson")
                    {
                        delay = poisson(0.3);
                        event = new cMessage("event-poisson");
                    }
            else
            {
                if((msg -> getFullName())=="onoff")
                        {
                            delay = poisson(0.3);
                            event = new cMessage("event-onoff");
                        }
                else
                {


                                delay = poisson(0.3);
                                event = new cMessage("event-mmpp");

                }
            }
        }



        scheduleAt(simTime()+delay, event);*/
}
